package com.xinchili.autoddl.autoClass.resolver;

import java.util.*;
import lombok.Data;

/**
 *
 */
@Data
public class AbstractDdlResolverSon {

    // 改为protected，子类可以直接访问
    protected final Map<Class<?>, String> sqlTypes = initDefaultSqlTypes();

    // 初始化默认类型映射
    private Map<Class<?>, String> initDefaultSqlTypes() {
        Map<Class<?>, String> types = new HashMap<>();
        types.put(String.class, "VARCHAR(255)");
        types.put(int.class, "INT default 0");
        types.put(Integer.class, "INT default 0");
        types.put(long.class, "BIGINT");
        types.put(Long.class, "BIGINT");
        types.put(boolean.class, "TINYINT(1)");
        types.put(Boolean.class, "TINYINT(1)");
        types.put(java.util.Date.class, "DATETIME");
        types.put(java.time.LocalDate.class, "DATE");
        types.put(java.time.LocalDateTime.class, "DATETIME");
        return types;
    }

    // 提供获取类型映射的方法
    public Map<Class<?>, String> getSqlTypes() {
        return sqlTypes;
    }

    // 提供添加类型映射的方法
    public void addSqlType(Class<?> javaType, String sqlType) {
        sqlTypes.put(javaType, sqlType);
    }


}
